class Player {
  constructor() {
    // initsuccess
    this.events = {};
    this.isInitSuccess = false;
  }
  init() {
    setTimeout(() => { // 模仿耗时操作,假设两秒钟之后，播放器初始化完成
      this.isInitSuccess = true;
      this.emit('initsuccess','')
    }, 2000);
  }
  play() {
    if (!this.isInitSuccess) throw Error('播放器为初始化')
  }
  stop() {}

  on(eventNamve,cb){
    this.events[eventNamve] = (this.events[eventNamve] ? this.events[eventNamve].push(cb) : [cb]);
  }，
  emit(eventNamve,...args){
        (this.events[eventNamve] || []).forEach(eventCallBack => {
          eventCallBack(...args)
        });
  }
}

let player = new Player()

player.init();
player.on('initsuccess',()=>{
  console.log('初始化完成')
})

